	
	package com.cx.bank.util;
	
	import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;

import com.cx.bank.model.MoneyBean;
import com.cx.bank.model.UserBean;
	
	public class PropertiesUtil{
		private Properties props;	
		private String propertiesname;
		public PropertiesUtil(String filename){
			this.propertiesname=filename;
			this.props = new Properties();
		}
		public boolean InputFile() throws Exception{
			boolean flag =false;
			File file =new File(propertiesname);
			if(file.exists()){
				flag= false;			
			}
				flag =true;
				FileInputStream input = new FileInputStream(propertiesname);
				props.load(input);
				input.close();
			return flag;
			
		}
		public Properties OutputFile(UserBean user,MoneyBean money) throws Exception{
			 FileOutputStream out =new FileOutputStream(propertiesname);
			 props.setProperty("username", user.getUsername() );
			 props.setProperty("password", user.getPassword());
			 props.setProperty("money", 10.0+"");
			 props.setProperty("id_card","622"+money.getId());//设置卡号
			 props.store(out, "comments");
			 out.close();
			 
			 return props;
		}
		public void close(){
			
		}
	}
